package com.hc.api.utils;

import com.hc.comm.utils.StringUtil;
import com.hc.service.model.UserdataModel;
import org.apache.commons.collections.map.HashedMap;

import java.util.Map;

/**
 * Created by yx on 2017/3/31.
 */
public class UserInfoUtil {

//    // 生成秘钥
//    String salt = SecurityUtils.getRandomCode(8);
//    UserModel uModel = new UserModel();
//		uModel.setSalt(salt);
//		uModel.setPassword(SecurityUtils.md5(userDTO.getPassword() + salt));

    public static Map getAppUserInfo(UserdataModel model) {
        Map<Object, Object> paramMap = new HashedMap();
        paramMap.put("user_id", model.getId());
        if (StringUtil.isEmpty(model.getPortrait())) {
            paramMap.put("portrait", "");
        } else {
            paramMap.put("portrait", model.getPortrait());
        }
        if (StringUtil.isEmpty(model.getUserName())) {
            paramMap.put("user_name", "");
        } else {
            paramMap.put("user_name", model.getUserName() + "");
        }
        if (StringUtil.isEmpty(model.getTelephone())) {
            paramMap.put("telephone", "");
        } else {
            paramMap.put("telephone", model.getTelephone() + "");
        }
        if (StringUtil.isEmpty(model.getAppToken())) {
            paramMap.put("access_token", "");
        } else {
            paramMap.put("access_token", model.getAppToken() + "");
        }
        return paramMap;
    }
}
